<template>
  <div class="skill-detail">
    <div class="nav-bar">
      <i class="iconfont icon-zuojiantou" @click="$router.go(-1)"></i>
    </div>
    <div class="main-box">
      <div class="skill-item">
        <div class="content">
          <div class="title">{{ skilldetail.title }}</div>
          <div class="info">
            <div class="time">{{ formatTime(skilldetail.created_at) }}</div>
            <div class="see">
              <van-icon name="eye-o" size="17px" /><span>{{
                skilldetail.read
              }}</span>
            </div>
            <div class="zan">
              <van-icon name="good-job-o" size="17px" /><span>{{
                skilldetail.star
              }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="main-content" ref="content"></div>
    </div>
  </div>
</template>

<script>
import { skillDetail } from '@/api/skill'
export default {
  data () {
    return {
      skilldetail: {
        default: '',
        type: String
      },
      id: this.$route.params.id
    }
  },
  created () {
    this.loadData()
  },
  methods: {
    async loadData () {
      const res = await skillDetail(this.id)
      this.skilldetail = res.data
      this.$refs.content.innerHTML = this.skilldetail.content
    },
    formatTime (date) {
      return this.dayjs(date).format('YYYY.MM.DD')
    }
  }
}
</script>

<style lang="less" scoped>
.skill-detail {
  .nav-bar {
    padding: 10px 10px;
    text-align: left;
    border-bottom: 0.5px solid #ebedf0;
    .iconfont {
      font-size: 25px;
      color: #3a3a3a;
    }
  }
  .main-box {
    padding: 10px 20px;
    font-size: 16px;
    .skill-item {
      .content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .title {
          text-align: left;
        }
        .info {
          color: #b4b4bd;
          font-size: 12px;
          display: flex;
          align-items: center;
          margin-top: 10px;
          span {
            margin-left: 8px;
          }
          .time {
            flex: 1;
            text-align: left;
          }
          .see {
            display: flex;
            align-items: center;
            margin-right: 25px;
          }
          .zan {
            display: flex;
            align-items: center;
          }
        }
      }
    }
    .main-content {
        padding-top: 20px;
        text-align: left;
        ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }
    }
  }
}
</style>
